import random
import time
import os
from Util.log import Log
from Util.read_accounts import ReadAccounts
import uiautomator2 as u2

from we_chat.add_friends_from_contact import AddFriendsFromContact

if __name__ == "__main__":

    currentAbsolutPath = os.getcwd();
    accountFilePath = os.path.join(currentAbsolutPath, "data/微信号模板_accounts.xlsx")
    readAccount = ReadAccounts()

    try:
        #链接设备
        d = u2.connect()
        # 设备解锁
        # d.unlock()
        #停用UiAutomator的守护程序
        d.service("uiautomator").stop()
        #检查并维持设备端守护进程处于运行状态
        d.healthcheck()
        d.debug = False

        addFriends = AddFriendsFromContact(d);
        if addFriends.showAddContactActivity():
            contactList = addFriends.getContactList()
            if contactList :
                addFriends.addContact(contactList)
    finally:
        pass

